#include <iostream>
using namespace std;

const int NMAX=10;

struct Stack
{ int a[NMAX];
  int n;
};  

void clear(Stack &s)
{ s.n=0; }

void push(Stack &s, int x)
{ if(s.n<NMAX)
  { s.a[s.n]=x; s.n++; }
}

int top(Stack &s)
{ return s.a[s.n-1]; }

void pop(Stack &s)
{ s.n--; }

int size(Stack &s)
{ return s.n; }

bool empty(Stack &s)
{ return s.n==0; }

int main()
{ Stack s;
    
  clear(s);
  push(s,10); push(s,15); push(s,12);
  cout << top(s) << endl;
  cout << size(s) << endl;
  pop(s);
  cout << top(s) << endl;
  cout << size(s) << endl;
  push(s,30);
  
  while(!empty(s))
  { cout << top(s) << " ";
    pop(s);
  }  
  cout << endl;
 
  return 0;
}    
    
  
